//初始化数据
$(function(){
	
	$.ajax({
		url: API_URL+'agenttop/findagent?openid='+openid,
		type: 'get',
		dataType: "JSON",
		data:'',
		async: false,
		success: function (obj){
			if (obj.status.code == 0) {
				var myData = obj.data;
				if(myData[0].icon == null || myData[0].icon == ''){
					myData[0].icon = '../img/default.png';
				}
				var agentStr = '<span class="name">'+myData[0].name+'</span>'+myData[0].phone;
				agentStr += '<img src="'+myData[0].icon+'" alt="">'
				$('.head_banner').html(agentStr);

			}else if(obj.status.code == 9999){
				/*
				var myData = obj.data;
				if(myData[0].icon == null || myData[0].icon == ''){
					myData[0].icon = '../img/default.png';
				}
				var agentStr = '<span class="name">'+myData[0].name+'</span>'+myData[0].phone;
				agentStr += '<img src="'+myData[0].icon+'" alt="">'
				$('.head_banner').html(agentStr);
				*/
				active_status();
			}else{
				alert('服务器错误');
			}
		},
		error: function (data){
			console.log("服务器异常!");
		}
	});
})

//判断活动是否已结束,并返回有多少人参与
function active_status(){
	var buttonStr='';
	//没有结束
	//buttonStr='<input class="play_start" type="button" onclick="active_start();"/>';
	//buttonStr += '<p class="num_content">已有<em>10298</em>人参与</p>';
	//已结束
	buttonStr='<input class="play_end" type="button"/>';
	buttonStr += '<p class="num_content">共有<em>113170</em>人参与</p>';
	$('#active_status').html(buttonStr);
	
}


//点击立即参与按钮
function active_start(){
	//window.location = 'share_active.html?origopenid='+openid+'&lastopenid='+openid;
}
